<template>
  <div
      style="width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center">
    <div class="but bgs">
      <div class="box" :style="{'background-color': item.status == 1? 'green':'red'}" v-for="(item, index) in list" :key="index">
        <samp class="samp" :style="{}">{{ item.name }}</samp>
      </div>
    </div>
    <div class="btn2 bgs" ref="div0">
      <div class="box2" ref="div1" v-for="(item, index) in list2" :key='index'>
        <div class="content1">
          <span>{{ item.name }}</span>
        </div>
        <Scroll :item="item" :sill="sill"></Scroll>
      </div>
    </div>
  </div>
</template>

<script>
import Scroll from "./scroll"
import Qs from 'qs'

export default {
  name: "index",
  components: {
    Scroll
  },
  data() {
    return {
      list: [],
      list2: [],
      sill: 0
    };
  },
  mounted() {
    this.getData();
    this.scroll()
  },
  methods: {
    getData() {
      this.$http.post(this.urlInterface.getPipelineAndReagent).then(res => {
        let data = res.data.data
        console.log(data.instrumentReagent, 'data')
        this.list = data.malfunctioningInstrument
        this.list2 = data.instrumentReagent
      })

      let data = {name: 'reagentAlarmCode'}
      this.$http.post("/large_screen/get_sys_config_by_name", Qs.stringify(data)).then(res => {
        this.sill = parseInt(res.data.data.code)
      })
    },
    scroll() {
      // setInterval(() => {
      //   console.log(this.$refs.div0.childNodes);
      // },1000)
    }
  },
};
</script>

<style lang="scss" scoped>
@import "src/assets/scss/public.scss";
/* :root { --size:50px } */
.box {
  --size: 4.2rem;
  width: var(--size);
  height: 40%;
  //background-color: red;
  line-height: 100%;
  display: flex;
  align-items: center;
  text-align: center;
  --margin-size: var(--size) *5;
  margin-right: calc((100% - var(--margin-size)) / 4);
  /* flex: 5; */
}

/* .box:nth-child(4n){
  margin-right: 0;
} */
.box:nth-child(5n) {
  margin-left: 0;
  margin-right: 0;
  //background: #06f;
}

.samp {
  width: 100%;
  font-size: 0.3rem;
  color: #fff;
}

.but {
  width: 96%;
  height: 18%;
  display: flex;
  /* justify-content: flex-start; */
  /* justify-content: space-evenly; */
  flex-wrap: wrap;
  /*background-color: hotpink;*/
}

.btn2 {
  padding-top: .6rem;
  padding-left: .2rem;
  padding-right: .2rem;
  width: 96%;
  height: 78%;
  margin-top: 2%;
  display: flex;
  /* justify-content: flex-start;
  justify-content: space-between;
  align-items: center; */
  flex-wrap: wrap;
  /*background-color: rebeccapurple;*/
}

.box2 {
  overflow: hidden;
  border-radius: 0.2rem;
  --size: 4.2rem;
  width: var(--size);
  height: 40%;
  line-height: 100%;
  --margin-size: var(--size)*5;
  margin-right: calc((100% - var(--margin-size)) / 4);

  .content1 {
    width: 100%;
    height: 20%;
    font-size: 0.3rem;
    color: #fff;
    background-color: #4046407D;
    display: flex;
    align-items: center;
    justify-content: center;
    border: #0f1325 solid 1px
  }

  .content2 {
    width: 100%;
    height: 25%;
    font-size: 0.3rem;
    color: black;
    display: flex;
    align-items: center;
    padding-left: .5rem;
    border-bottom: 1px #0f1325 solid
  }
}

.box2:nth-child(5n) {
  margin-left: 0;
  margin-right: 0;
  //background: #06f;
  overflow: hidden;
}
</style>
